import { defineStore } from "pinia";

export const useUserInfo = defineStore("userInfo", {
  state: () => ({
    userInfo: JSON.parse(localStorage.getItem("userInfo") || "{}") || {},
  }),
  getters: {},
  actions: {
    setUserInfo(info: object) {
      localStorage.setItem("userInfo", JSON.stringify(info));
      this.userInfo = info;
    },
    delUserInfo() {
      localStorage.removeItem("userInfo");
      localStorage.removeItem("token")
    },
  },
});
